//
//  DiseaseController.m
//  International_Hospital
//
//  Created by 张城 on 16/7/6.
//  Copyright © 2016年 LiYiLin. All rights reserved.
//

#import "DiseaseController.h"
#import "AddCaseController.h"

@interface DiseaseController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) NSArray * dataArray1;
@property (nonatomic,strong) NSArray * dataArray2;
@property (nonatomic,strong) UITableView * tableView;
@end

@implementation DiseaseController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.tableView];
//    self.view.backgroundColor = [UIColor blueColor];
    self.dataArray1 = @[@"肿瘤科",@"心血管科",@"血液科",@"神经科",@"骨科"];
    self.dataArray2 = @[@"第一行",@"第二行",@"第三行",@"第四行",@"第五行",@"第六行",@"第七行",@"第八行",@"第九行",@"第十行",@"第十一行",@"第十二行"];
    [self.tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
}

#pragma mark - tableView的数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (self.num == 1) {
        return self.dataArray1.count;
    }else{
        return self.dataArray2.count;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString * ss = @"123456";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:ss];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ss];
    }
    
    if (self.num ==1) {
        cell.textLabel.text = self.dataArray1[indexPath.row];
    }else{
       cell.textLabel.text = self.dataArray2[indexPath.row];
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSString * string;
    if (self.num == 1) {
         string = self.dataArray1[indexPath.row];
    }else{
        string = self.dataArray2[indexPath.row];
    }
    if (self.MyBlock) {
        self.MyBlock(string);
    }
    [self.navigationController popViewControllerAnimated:YES];
}

- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
    }
    return _tableView;
}

@end
